<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('采购申报实体列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <!--<div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>采购单位ID：</label>
                                <input type="text" name="purchasingUnitId"/>
                            </li>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="projectName"/>
                            </li>
                            <li>
                                <label>项目编号：</label>
                                <input type="text" name="projectNumber"/>
                            </li>
                            <li>
                                <label>单位名称：</label>
                                <input type="text" name="unitName"/>
                            </li>
                            <li>
                                <label>联系人：</label>
                                <input type="text" name="contactName"/>
                            </li>
                            <li>
                                <label>固定电话：</label>
                                <input type="text" name="tel"/>
                            </li>
                            <li>
                                <label>手机号：</label>
                                <input type="text" name="mobilePhone"/>
                            </li>
                            <li>
                                <label>计划资金：</label>
                                <input type="text" name="expectMoney"/>
                            </li>
                            <li class="select-time">
                                <label>计划资金：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCreateTime]"/>
                            </li>
                            <li>
                                <label>扩展字段1：</label>
                                <input type="text" name="attribite1"/>
                            </li>
                            <li>
                                <label>扩展字段3：</label>
                                <input type="text" name="attribite3"/>
                            </li>
                            <li>
                                <label>扩展字段2：</label>
                                <input type="text" name="attribite2"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>-->

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:procurementdeclare:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:procurementdeclare:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:procurementdeclare:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:procurementdeclare:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:procurementdeclare:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:procurementdeclare:remove')}]];
        var listFlag = [[${@permission.hasPermi('system:procurementdeclare:list')}]];
        var shenpiFlag = [[${@permission.hasPermi('system:declaregoods:shenpi')}]];
        var datas = [[${@dict.getType('sys_approve_status')}]];
        var yulanFlag = [[${@permission.hasPermi('system:procurementdeclare:yulan')}]];
        var prefix = ctx + "system/procurementdeclare";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "采购申报实体",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'procurementDeclareId',
                    title: '采购申报表ID',
                    visible: false
                },
                    {
                        field: 'projectNumber',
                        title: '项目编号'
                    },
                {
                    field: 'projectName',
                    title: '项目名称',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return '<a href="javascript:void(0)" onclick="detail(\'' + row.procurementDeclareId + '\',\'' + row.cgbApproveResult + '\')">' + value + '</a>';
                    }
                },
                {
                    field: 'unitName',
                    title: '单位名称'
                },
                {
                    field: 'contactName',
                    title: '联系人'
                },
                {
                    field: 'tel',
                    title: '固定电话'
                },
                {
                    field: 'mobilePhone',
                    title: '手机号'
                },
                {
                    field: 'expectMoney',
                    title: '计划资金(万元)'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                    {
                        field: 'cgbApproveResult',
                        title: '审核状态',
                        formatter: function(value, row, index) {
                            // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                            // 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                            if(value=='0'){
                                return "未审批"
                            }else if(value=='1'){
                                return '同意，已审批'
                            }else if(value=='-1'){
                                return "不同意";
                            }else if(value=='-2'){
                                return "作废";
                            }else{
                                return "未审批"
                            }



                        }
                    },
                    {
                        field: 'attribute3',
                        title: '状态',
                        align: 'center',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(datas, value);
                        }
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + yulanFlag + '" href="javascript:void(0)" onclick="yulan(\'' + row.procurementDeclareId + '\')"><i class="fa fa-edit"></i>预览</a> ');
                        /*actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.procurementDeclareId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.procurementDeclareId + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        if(row.cgbApproveResult==0||row.cgbApproveResult==-1||row.cgbApproveResult==''||row.cgbApproveResult==null||row.cgbApproveResult==undefined){
                            actions.push('<a class="btn btn-info btn-xs ' + listFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.procurementDeclareId + '\')"><i class="fa fa-list-ul"></i>添加采购商品</a> ');
                            actions.push('<a class="btn btn-info btn-xs ' + shenpiFlag + '" href="javascript:void(0)" onclick="shenpi(\'' + row.procurementDeclareId + '\')"><i class="fa fa-list-ul"></i>提交审批</a> ');
                        }

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        /*添加采购商品*/
        function detail(procurementDeclareId,cgbApproveResult) {
            var url = prefix + '/detail?procurementDeclareId=' + procurementDeclareId+"&cgbApproveResult="+cgbApproveResult;
            $.modal.openTab("添加采购商品", url);
        }
        /*提交审批*/
        function shenpi(procurementDeclareId) {
            var url = '/system/declaregoods/shenpi/' + procurementDeclareId;
            $.modal.open("提交审批", url, '800', '600');
        }
        /**
         * 申报表预览
         * @param approveId
         */
        function yulan(procurementDeclareId) {
            var url = prefix +'/yulan/' + procurementDeclareId;
            $.modal.open("预览", url, '800', '600');
        }
    </script>
</body>
</html>